package org.example.sb_api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.sb_api.annotation.RequireLogin;
import org.example.sb_api.common.Result;
import org.example.sb_api.dto.AppRecordDTO;
import org.example.sb_api.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "应用管理")
@RestController
@RequestMapping("/api/app")
public class AppController {

    @Autowired
    private AppService appService;

    @ApiOperation("获取应用列表")
    @GetMapping("/list")
    public Result getAppList(
            @RequestParam(required = false) Integer isRecommended,
            @RequestParam(required = false) Integer isUpdated) {
        return appService.getAppList(isRecommended, isUpdated);
    }

    @ApiOperation("获取专题列表")
    @GetMapping("/topic/list")
    public Result getTopicList() {
        return appService.getTopicList();
    }

    @ApiOperation("添加下载记录")
    @PostMapping("/download/record")
    @RequireLogin
    public Result addDownloadRecord(@RequestBody AppRecordDTO recordDTO) {
        return appService.addDownloadRecord(recordDTO);
    }
}
